package com.zzzyh.bookbackgroundsystem.aspect;

import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.stereotype.Component;

@Aspect
@Slf4j
@Component
public class TimeAspect {

    @Around("execution(* com.zzzyh.bookbackgroundsystem.controller.*.*(..))")
    public Object getTime(ProceedingJoinPoint joinPoint) throws Throwable {
        Long start = System.currentTimeMillis();
        Object ret = joinPoint.proceed();
        Long end = System.currentTimeMillis();
        log.info(joinPoint+"运行时间: {}", end - start);
        return ret;
    }
}
